import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { GangFightsInviteFriendCellRenderer } from "./cellRenderer/GangFightsInviteFriendCellRenderer";
import { Cache } from "../../cache/Cache";
import { FriendInfo } from "../../model/FriendInfo";
import { SGangFightsTeamMember } from "../../../../Message/Public/SGangFightsTeamMember";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { GTabBar } from "../../../../com/mui/controls/GTabBar";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { GButton } from "../../../../com/mui/controls/GButton";
//class GangFightsInviteToTeamWindow
    
    export  class GangFightsInviteToTeamWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            this._tabBarData = [{"label":"好友", "name":"friend"}];
            super(arg1);
            setSize(240, 390);
            titleHeight = 26;
            title = Language.getString(44475);
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            this.updateData();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._tabBar = ObjCreate.createGTabBar(24, 38, this._tabBarData, 50, 22, this);
            ObjCreate.createBg(18, 60, 204, 283, this);
            this._tileList = ObjCreate.createTileList(19, 62, 200, 280, this);
            this._tileList.columnWidth = 200;
            this._tileList.rowHeight = 30;
            this._tileList.setStyle("cellRenderer", GangFightsInviteFriendCellRenderer);
            this._btnOK = ObjCreate.createGButton(Language.getString(44476), 86, 351, 60, 24, this);
            this._btnOK.addEventListener(flash.events.MouseEvent.CLICK, this.onClickOK);
            return;
        }

        /* internal  */onClickOK(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hide();
            return;
        }

        /* internal  */updateData(): void
        {
            var loc2=null;
            var loc3=0;
            var loc4=null;
            var loc5=0;
            var loc6=null;
            var loc1=Cache.instance.friend.getFriendArrayList();
            if (Cache.instance.gangFights.myTeamInfo) 
            {
                loc2 = Cache.instance.gangFights.myTeamInfo.members;
                loc3 = (loc1.length - 1);
                while (loc3 >= 0) 
                {
                    loc4 = loc1[loc3] as FriendInfo;
                    loc5 = 0;
                    while (loc5 < loc2.length) 
                    {
                        if ((loc6 = loc2[loc5] as SGangFightsTeamMember).name == loc4.friendPlayerInfo.miniPlayer.name) 
                        {
                            loc1.splice(loc3, 1);
                            break;
                        }
                        ++loc5;
                    }
                    --loc3;
                }
            }
            this._tileList.dataProvider = new DataProvider(loc1);
            this._tileList.drawNow();
            return;
        }

        public static get instance(): GangFightsInviteToTeamWindow
        {
            if (!GangFightsInviteToTeamWindow._instance) 
            {
                GangFightsInviteToTeamWindow._instance = new GangFightsInviteToTeamWindow();
            }
            return GangFightsInviteToTeamWindow._instance;
        }

        public static hasInstance(): Boolean
        {
            return !(GangFightsInviteToTeamWindow._instance == null);
        }

        /* internal */ /* var */_tabBarData: Array<any>;

        /* internal */ /* var */_tabBar: GTabBar;

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_btnOK: GButton;

        /* internal */ static /* var */_instance: GangFightsInviteToTeamWindow;
    }
